package com.moxiao.yfjh.module.activity.dal.mysql.merchanType;

import java.util.*;

import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import com.moxiao.yfjh.module.activity.dal.dataobject.merchanType.MerchantTypeDO;
import org.apache.ibatis.annotations.Mapper;
import com.moxiao.yfjh.module.activity.controller.admin.merchanType.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 相亲商家类型 Mapper
 *
 * @author mx
 */
@Mapper
public interface MerchantTypeMapper extends BaseMapperX<MerchantTypeDO> {

    default PageResult<MerchantTypeDO> selectPage(MerchantTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MerchantTypeDO>()
                .eqIfPresent(MerchantTypeDO::getNo, reqVO.getNo())
                .likeIfPresent(MerchantTypeDO::getName, reqVO.getName())
                .eqIfPresent(MerchantTypeDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(MerchantTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MerchantTypeDO::getId));
    }

    default List<MerchantTypeDO> selectList(MerchantTypeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MerchantTypeDO>()
                .eqIfPresent(MerchantTypeDO::getNo, reqVO.getNo())
                .likeIfPresent(MerchantTypeDO::getName, reqVO.getName())
                .eqIfPresent(MerchantTypeDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(MerchantTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MerchantTypeDO::getId));
    }

    @Select("select count(*) num from blind_merchant_info where no = #{merchantTypeNo}")
    Integer getMerchantTypeNo(@Param("merchantTypeNo") String merchantTypeNo);

}
